﻿using System;
using System.Collections.Generic;

namespace Little.Soldier.SWIFT.Validation
{
  public class ValidationRule_Enumeration : ValidationRuleBase
  {
    private static string U0003 = string.Empty;
    private List<string> U0001 = new List<string>();
    private bool U0002;

    static ValidationRule_Enumeration()
    {
    }

    public ValidationRule_Enumeration(params string[] values)
    {
      foreach (string str in values)
        this.U0001.Add(str);
    }

    public ValidationRule_Enumeration(int startIndex, params string[] values)
    {
      foreach (string str in values)
        this.U0001.Add(str);
      this.StartIndex = startIndex;
    }

    public ValidationRule_Enumeration(int startIndex, int length, params string[] values)
    {
      foreach (string str in values)
        this.U0001.Add(str);
      this.StartIndex = startIndex;
      this.Length = length;
    }

    public ValidationRule_Enumeration(string errorDescription, bool caseSensitive, params string[] values)
    {
      this.ErrorDescription = errorDescription;
      foreach (string str in values)
        this.U0001.Add(str);
      this.U0002 = caseSensitive;
    }

    public ValidationRule_Enumeration(int startIndex, int length, string errorDescription, bool caseSensitive, params string[] values)
    {
      this.ErrorDescription = errorDescription;
      foreach (string str in values)
        this.U0001.Add(str);
      this.U0002 = caseSensitive;
      this.StartIndex = startIndex;
      this.Length = length;
    }

    public ValidationRule_Enumeration(char delimiter, int count, string errorDescription, bool caseSensitive, params string[] values)
    {
      this.ErrorDescription = errorDescription;
      foreach (string str in values)
        this.U0001.Add(str);
      this.U0002 = caseSensitive;
      this.Delimiter = delimiter;
      this.Count = count;
    }

    public ValidationRule_Enumeration(int startIndex, string errorDescription, bool caseSensitive, params string[] values)
    {
      this.ErrorDescription = errorDescription;
      foreach (string str in values)
        this.U0001.Add(str);
      this.U0002 = caseSensitive;
      this.StartIndex = startIndex;
    }

    public ValidationRule_Enumeration(bool caseSensitive, params string[] values)
    {
      foreach (string str in values)
        this.U0001.Add(str);
      this.U0002 = caseSensitive;
    }

    public ValidationRule_Enumeration(char delimiter, int count, bool caseSensitive, params string[] values)
    {
      foreach (string str in values)
        this.U0001.Add(str);
      this.U0002 = caseSensitive;
      this.Delimiter = delimiter;
      this.Count = count;
    }

    public override ValidationError[] Validate(string value)
    {
      bool flag;
      if (!this.U0002)
      {
        ValidationRule_Enumeration.U0003 = value;
        flag = this.U0001.Find(new Predicate<string>(ValidationRule_Enumeration.U0089U0003)) != null;
      }
      else
        goto label_7;
label_2:
      if (flag)
        return new ValidationError[0];
      if (string.IsNullOrEmpty(this.ErrorDescription))
        return new ValidationError[1]
        {
          new ValidationError(ValidationErrorType.UnsupportedValue, string.Format("The value '{0}' is not supported.", (object) value))
        };
      else
        return new ValidationError[1]
        {
          new ValidationError(ValidationErrorType.UnsupportedValue, this.ErrorDescription)
        };
label_7:
      flag = this.U0001.Contains(value);
      goto label_2;
    }

    private static bool U0089U0003(string s)
    {
      return ValidationRule_Enumeration.U0003.ToLower() == s.ToLower();
    }
  }
}
